﻿<!DOCTYPE html>
<html lang="en">
<head>
    <title>对象序列化</title>
</head>
<body>
    <script>
        let str = { "name": "淘宝网址", "site": "http://www.taobao.com" }
        str_pretty1 = JSON.stringify(str)
        document.write("只有一个参数情况：");
        document.write("<br>");
        document.write("<pre>" + str_pretty1 + "</pre>");
        document.write("<br>");
        str_pretty2 = JSON.stringify(str, null, 4) //使用四个空格缩进
        document.write("使用参数情况：");
        document.write("<br>");
        document.write("<pre>" + str_pretty2 + "</pre>"); // pre 用于格式化输出
    </script>
</body>
</html>
